function getNumber(n) {
    let ans = 0;
    let carry = 0;
    for (let i = n; i >= 1; i--) {
        let temp = i+carry;
        if(temp%10 === 1) ans++;
        carry = Math.floor(temp/10);
    }
    return ans;
}
console.log(getNumber(2009));